<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品分类管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
			var data = ${fns:toJson(list)}, rootId = "0";
			addRow("#treeTableList", tpl, data, rootId, true);
			$("#treeTable").treeTable({expandLevel : 6});
		});
		function addRow(list, tpl, data, pid, root){
			for (var i=0; i<data.length; i++){
				var row = data[i];
				if ((${fns:jsGetVal('row.parentId')}) == pid){
					$(list).append(Mustache.render(tpl, {
						dict: {
							//type: getDictLabel(${fns:toJson(fns:getDictList('sys_area_type'))}, row.type)
						}, pid: (root?0:pid), row: row
					}));
					addRow(list, tpl, data, row.id);
				}
			}
		}

	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/goods/goodsCategory/">商品分类列表</a></li>
		<shiro:hasPermission name="goods:goodsCategory:edit"><li><a href="${ctx}/goods/goodsCategory/form">商品分类添加</a></li></shiro:hasPermission>
	</ul>
	<sys:message content="${message}"/>

	<table id="treeTable" class="table table-striped table-bordered table-condensed">
		<thead><tr><th>分类名称</th><th>分类编号</th><th>分类排序</th><th>分类说明</th><shiro:hasPermission name="goods:goodsCategory:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody id="treeTableList"></tbody>
	</table>
	<script type="text/template" id="treeTableTpl">
		<tr id="{{row.id}}" pId="{{pid}}">
			<td><a href="${ctx}/goods/goodsCategory/form?id={{row.id}}">{{row.categoryName}}</a></td>
			<td>{{row.categoryCode}}</td>
			<td>{{row.sort}}</td>
			<td>{{row.remarks}}</td>
			<shiro:hasPermission name="goods:goodsCategory:edit"><td>
				<a href="${ctx}/goods/goodsCategory/form?id={{row.id}}">修改</a>
				<a href="${ctx}/goods/goodsCategory/delete?id={{row.id}}" onclick="return confirmx('要删除该分类及所有子分类项吗？', this.href)">删除</a>
				<a href="${ctx}/goods/goodsCategory/form?parent.id={{row.id}}">添加下级分类</a>
			</td></shiro:hasPermission>
		</tr>
	</script>


	<%--<form:form id="searchForm" modelAttribute="goodsCategory" action="${ctx}/goods/goodsCategory/" method="post" class="breadcrumb form-search">--%>
		<%--<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>--%>
		<%--<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>--%>
		<%--<ul class="ul-form">--%>
			<%--<li><label>类别名称：</label>--%>
				<%--<form:input path="categoryName" htmlEscape="false" maxlength="50" class="input-medium"/>--%>
			<%--</li>--%>
			<%--<li><label>类别编码：</label>--%>
				<%--<form:input path="categoryCode" htmlEscape="false" maxlength="50" class="input-medium"/>--%>
			<%--</li>--%>
			<%--<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>--%>
			<%--<li class="clearfix"></li>--%>
		<%--</ul>--%>
	<%--</form:form>--%>
	<%--<sys:message content="${message}"/>--%>
	<%--<table id="contentTable" class="table table-striped table-bordered table-condensed">--%>
		<%--<thead>--%>
			<%--<tr>--%>
				<%--<th>类别名称</th>--%>
				<%--<th>类别编码</th>--%>
				<%--<th>排序</th>--%>
				<%--<th>创建时间</th>--%>
				<%--<th>备注</th>--%>
				<%--<shiro:hasPermission name="goods:goodsCategory:edit"><th>操作</th></shiro:hasPermission>--%>
			<%--</tr>--%>
		<%--</thead>--%>
		<%--<tbody>--%>
		<%--<c:forEach items="${page.list}" var="goodsCategory">--%>
			<%--<tr>--%>
				<%--<td><a href="${ctx}/goods/goodsCategory/form?id=${goodsCategory.id}">--%>
					<%--${goodsCategory.categoryName}--%>
				<%--</a></td>--%>
				<%--<td>--%>
					<%--${goodsCategory.categoryCode}--%>
				<%--</td>--%>
				<%--<td>--%>
					<%--${goodsCategory.sort}--%>
				<%--</td>--%>
				<%--<td>--%>
					<%--<fmt:formatDate value="${goodsCategory.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
				<%--</td>--%>
				<%--<td>--%>
					<%--${goodsCategory.remarks}--%>
				<%--</td>--%>
				<%--<shiro:hasPermission name="goods:goodsCategory:edit"><td>--%>
    				<%--<a href="${ctx}/goods/goodsCategory/form?id=${goodsCategory.id}">修改</a>--%>
					<%--<a href="${ctx}/goods/goodsCategory/delete?id=${goodsCategory.id}" onclick="return confirmx('确认要删除该商品分类吗？', this.href)">删除</a>--%>
				<%--</td></shiro:hasPermission>--%>
			<%--</tr>--%>
		<%--</c:forEach>--%>
		<%--</tbody>--%>
	<%--</table>--%>
	<%--<div class="pagination">${page}</div>--%>
</body>
</html>